package controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
	"yuce/result"
	"yuce/service"
)

func GetSinHand(c *gin.Context) {
	isFront, b := c.GetQuery("isFront")
	if !b {
		c.JSON(http.StatusOK, result.Err.WithMsg("获取请求参数错误"))
	}
	boolValue, err := strconv.ParseBool(isFront)
	if err != nil {
		c.JSON(http.StatusOK, result.Err.WithMsg("bool转化失败"))
		return
	}
	jijiang := service.Jisuan{}
	results := jijiang.SinNum(
		service.CalculateSin,
		boolValue,
	)
	c.JSON(http.StatusOK, result.OK.WithData(results))
}
func GetCosHand(c *gin.Context) {
	isFront, b := c.GetQuery("isFront")
	if !b {
		c.JSON(http.StatusOK, result.Err.WithMsg("获取请求参数错误"))
	}
	boolValue, err := strconv.ParseBool(isFront)
	if err != nil {
		c.JSON(http.StatusOK, result.Err.WithMsg("bool转化失败"))
		return
	}
	jijiang := service.Jisuan{}
	results := jijiang.SinNum(
		service.CalculateCos,
		boolValue,
	)
	c.JSON(http.StatusOK, result.OK.WithData(results))
}
func GetGenHand(c *gin.Context) {
	isFront, b := c.GetQuery("isFront")
	if !b {
		c.JSON(http.StatusOK, result.Err.WithMsg("获取请求参数错误"))
	}
	boolValue, err := strconv.ParseBool(isFront)
	if err != nil {
		c.JSON(http.StatusOK, result.Err.WithMsg("bool转化失败"))
		return
	}
	jijiang := service.Jisuan{}
	results := jijiang.SinNum(
		service.GetDecimalSum,
		boolValue,
	)
	c.JSON(http.StatusOK, result.OK.WithData(results))
}

func GetLogHand(c *gin.Context) {
	isFront, b := c.GetQuery("isFront")
	if !b {
		c.JSON(http.StatusOK, result.Err.WithMsg("获取请求参数错误"))
	}
	boolValue, err := strconv.ParseBool(isFront)
	if err != nil {
		c.JSON(http.StatusOK, result.Err.WithMsg("bool转化失败"))
		return
	}
	jijiang := service.Jisuan{}
	results := jijiang.SinNum(
		service.GetLogNumvalue,
		boolValue,
	)
	c.JSON(http.StatusOK, result.OK.WithData(results))
}
